<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use app\models\Helpers;
use yii\widgets\Breadcrumbs;
use app\modules\clinical\models\Patient;
use app\modules\clinical\models\Check;

/* @var $this yii\web\View */
/* @var $model app\models\Check */

$this->title = '查看辅助检查';
$this->params['breadcrumbs'][] = ['label' => '临床信息', 'url' => ['/clinical/patient']];
$this->params['breadcrumbs'][] = ['label' => '辅助检查', 'url' => ['/clinical/check']];
$this->params['breadcrumbs'][] = $this->title;

$pic = Helpers::checkExist("check", empty($model->pic_id) ? 'xxx' : $model->pic_id);
$rel = $pt_rel_list;
?>

<?= Breadcrumbs::widget([
    'homeLink' => ['label' => '医疗管理系统', 'url' => '#'],
    'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>

<div class="check-view">

    <p>
        <?= Html::a('修改', ['update', 'id' => $model->pk_id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('返回', '/clinical/check', ['class' => 'btn btn-success']) ?>

        <?= Html::a('删除', ['delete', 'id' => $model->pk_id], [
            'class' => 'btn btn-danger btn-right',
            'data' => [
                'confirm' => '确定删除?',
                'method' => 'post',
            ],
        ]) ?>
    </p>

    <table class="table table-striped table-bordered detail-view">
        
        <tr class="title">
            <td colspan="6"><h4>一、样本基本信息</h4></td>
        </tr>
        <tr>
            <th>姓名：</th>
            <td><?= ($model->rel_id == 0) ? Yii::$app->session->get('pt_name') : Patient::findOne(['pk_id'=>$model->pt_id])->pt_name ?></td>
            <th>与患者关系</th>
            <td colspan="3"><?= ($model->rel_id == 0) ? '本人' : Patient::getParams('relation')[$rel[$model->pt_id]] ?></td>
        </tr>
        <tr>
            <th>报告日期</th>
            <td><?= $model->ck_date ?></td>
            <th>类别</th>
            <td><?= Check::getParams('check_type')[$model->ck_type] ?></td>
            <th>检查项目</th>
            <td><?= Check::getParams('ck_program')[$model->ck_program] ?></td>
        </tr>
        <tr>
            <th>检查结果</th>
            <td colspan="3"><?= $model->ck_result ?></td>
            <td colspan="2" rowspan="<?= ($model->ck_type == 'lab') ? 4 : 3 ?>">
                <a href="<?= $pic['href'] ?>" target="_blank">
                    <img <?= $pic['name'] ?> width="200px">
                </a>
            </td>
        </tr>
        <?php if ($model->ck_type == 'lab') : ?>
        <tr>
            <th>单位</th>
            <td><?= $model->ck_range ?></td>
            <th>参考范围</th>
            <td><?= $model->ck_unit ?></td>
        </tr>
        <?php endif; ?>
        <tr>
            <th>创建人</th>
            <td><?= $model->crt_name ?></td>
            <th>创建时间</th>
            <td><?= $model->crt_time ?></td>
        </tr>
        <tr>
            <th>修改人</th>
            <td><?= $model->update_name ?></td>
            <th>修改时间</th>
            <td><?= $model->update_at ?></td>
        </tr>
    </table>

</div>
